Skip to content

test: pass the expected object to toMatchObject in url-parse-ipv6 and net.Server tests - #47735

Open
robobun wants to merge 1 commit into
mainfrom
robobun/fd48c6eb/url-parse-ipv6-expectations
Open

robobun wants to merge 1 commit into
mainfrom
robobun/fd48c6eb/url-parse-ipv6-expectations

Conversation

@robobun

@robobun robobun commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Fix

  • Give the expected object to toMatchObject directly, in both files.
  • Correct the three rows to what url.parse returns in Node 26.3.0 and in Bun: http://[::1]:1 keeps its port in host and href, http://[::F] has the host [::f], and [0:0:0:1:2:3:4:5] has no protocol, so it is a path and host is null.
  • Verified on a release build of main (271b65e): without the wrapper, 3 rows of url-parse-ipv6.test.ts fail. With the corrected rows, both files pass (74 pass, 3 skip).

Background


[auto-merge] gate passed · iteration 0 · 2 files touched

passes on PR (with fix)
Test-only change.

Debug/ASAN (expected pass):
$ bun bd test 'test/js/node/url/url-parse-ipv6.test.ts'
$ BUN_DEBUG_QUIET_LOGS=1 bun scripts/build.ts --profile=debug --quiet test "test/js/node/url/url-parse-ipv6.test.ts"
bun test v1.4.4 (367d939d9)

test/js/node/url/url-parse-ipv6.test.ts:
(pass) Invalid IPv6 addresses > Invalid hostnames - parsing 'https://[::1' fails [30.37ms]
(pass) Invalid IPv6 addresses > Lenient hostnames - parsing 'https://[:::1]' [9.46ms]
(pass) Invalid IPv6 addresses > Lenient hostnames - parsing 'https://[
::1]' [9.74ms]
(pass) Invalid IPv6 addresses > Lenient hostnames - parsing 'http://[::banana]' [1.58ms]
(pass) Invalid IPv6 addresses > Invalid ports - parsing 'https://[::1]::' fails [3.61ms]
(pass) Invalid IPv6 addresses > Invalid ports - parsing 'https://[::1]:foo' fails [0.99ms]
(pass) Valid spot checks > Parsing 'http://[::1]:' succeeds [1.77ms]
(pass) Valid spot checks > Parsing 'http://[::1]:1' succeeds [1.25ms]
(pass) Valid spot checks > Parsing 'http://[::0]' succeeds [0.93ms]
(pass) Valid spot checks > Parsing 'http://[::f]' succeeds [0.83ms]
(pass) Valid spot checks > Parsing 'http://[::F]' succeeds [0.81ms]
(pass) Valid spot checks > Parsing 'http://[::7]' succeeds [2.33ms]
(pass) Valid spot checks > Parsing 'https://[::1:2:3:4:5]' succeeds [1.21ms]
(pass) Valid spot checks > Parsing '[0:0:0:1:2:3:4:5]' succeeds [1.13ms]
(pass) Valid > url.parse("[::1]") > parses to the expected object [0.77ms]
(pass) Valid > url.parse("[::1]") > is a Url, not a URL [1.05ms]
(pass) Valid > url.parse("[::1]", true) > parses to the expected object [1.68ms]
(pass) Valid > url.parse("[::1]", true) > parses the query [0.91ms]
(pass) Valid > url.parse("https://[::1]") > parses to the expected object [0.35ms]
(pass) Valid > url.parse("https://[::1]") > is a Url, not a URL [0.30ms]
(pass) Valid > url.parse("https://[::1]", true) > parses to the expected object [0.39ms]
(pass) Valid > url.parse("https://[::1]", true) > parses the query [0.25ms]
(pass) Valid > url.parse("http://user@[::1]:3000/foo/bar#baz?a=hi&b=1&c=%20") > parses to the 
... (truncated)
Exit: 0
diff hotspot
test/js/node/net/server.spec.ts         | 18 ++++++++----------
 test/js/node/url/url-parse-ipv6.test.ts | 10 +++++-----
 2 files changed, 13 insertions(+), 15 deletions(-)

gate history · 1 passed · 0 rejected · iteration 0

evidence per changed file
file                                     reads  edits  tests
test/js/node/net/server.spec.ts              0      0     33
test/js/node/url/url-parse-ipv6.test.ts      0      0     24

… net.Server tests

Both files wrapped the expected object in expect.objectContaining() and gave
the matcher to toMatchObject. toMatchObject walks the enumerable keys of the
expected value, and a matcher has none, so nothing was compared. Three
expected values of url-parse-ipv6.test.ts were wrong. They now hold what
url.parse returns in Node 26.3.0 and in Bun.
@github-actions github-actions Bot added the claude label Nov 2, 2026
@coderabbitai

coderabbitai Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 2 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 271b65e and 141ec6a.

Files selected for processing: 2
  • test/js/node/net/server.spec.ts
  • test/js/node/url/url-parse-ipv6.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@robobun

robobun commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

Status: ready for review. Test-only.

Reproduced on a release build of main (271b65e): with toMatchObject(expected) in place of toMatchObject(expect.objectContaining(expected)), three rows of test/js/node/url/url-parse-ipv6.test.ts fail (http://[::1]:1, http://[::F], [0:0:0:1:2:3:4:5]). With the corrected expected values both files pass.

CI (build 136856): the two test files of this PR pass on every lane. Each red test is under test/aot/ or is test/bundler/compile-aot-size.test.ts. Those fail on main too.

@robobun

robobun commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator Author
Updated 6:23 AM PT - Nov 2nd, 2026

❌ @robobun, your commit 141ec6a has 40 failures in Build #136856 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 47735

That installs a local version of the PR into your bun-47735 executable, so you can run:

bun-47735 --bun

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — test-only change that turns a vacuous toMatchObject(expect.objectContaining(...)) into a live assertion and corrects the three rows that had been silently wrong.

What was reviewed:

  • Traced the three corrected rows through src/js/node/url.ts: port is appended to host/href (lines 411-414), the hostname is lowercased before the IPv6 branch (line 383), and a protocol-less bracketed input never enters the host branch, consistent with the already-live [::1] row in the describe.each block.
  • Checked the sibling rows that are now live: the trailing-colon row matches parseHost (port ":" is dropped), and the url.parse(input, true) form sets search: null with a null-prototype query when there is no query string, matching Node.
  • Confirmed all six net.Server.prototype methods are own enumerable Server.prototype.X = function assignments in src/js/node/net.ts, so the now-strict toMatchObject cannot fail spuriously.
Extended reasoning...

The diff touches only two test files (test/js/node/url/url-parse-ipv6.test.ts and test/js/node/net/server.spec.ts), removing an expect.objectContaining wrapper from toMatchObject at four call sites and correcting three expected rows in the IPv6 spot-check table; no runtime code changes. It touches no security-sensitive surface. Approval was decided by the change being small and mechanical, by every corrected expectation and every newly live sibling row tracing directly to Bun's url.parse and net.Server implementations (which mirror Node's), and by the changed files not being covered by CODEOWNERS; the bug hunt exited on dry_streak with no findings.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant